﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Bridge.Shared.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc;
using Vouchers.InStockVouchers;
using Vouchers.InStockVouchers.Input;
using Vouchers.InStockVouchers.Output;

namespace Vouchers
{
    [Route("[controller]/[action]")]
    public class InStockVoucherController : AbpController
    {
        private  IInStockVoucherService _inStockVoucherService { get; set; }
        public InStockVoucherController(IInStockVoucherService inStockVoucherService) {

            _inStockVoucherService=inStockVoucherService;
        }
        [HttpPost]
        public async Task<ResponseResult> CreateOrUpdate([FromBody]CreateOrUpdateInStockVoucherInput input)
        {
            try
            {
                await _inStockVoucherService.CreateOrUpdate(input);
            }
            catch (Exception ex)
            {
                return ResponseResult.Fail(ex.Message);
            }
            return ResponseResult.Success("操作成功！");

        }

        [HttpPost]
       public async Task<PageResponseResult<InStockVoucherOutput>> GetPageList([FromBody] GetInStockVoucherInput input)
        {
            try
            {
               var dto = await _inStockVoucherService.GetPageList(input);
                return dto;
            }
            catch (Exception ex)
            {
                return PageResponseResult<InStockVoucherOutput>.Fail(ex.Message);
            }
            
        }


        [HttpPost]
      public async  Task<PageResponseResult<InStockVoucherDetailOutput>> GetDetailById([FromBody] GetDetailInput input)
        {
            try
            {
               var dto =  await _inStockVoucherService.GetDetailById(input);
                return dto;
            }
            catch (Exception ex)
            {
                return PageResponseResult<InStockVoucherDetailOutput>.Fail(ex.Message);
            }
            
        }

        [HttpPost]
       public async Task<ResponseResult> SubmitInStockVoucher([FromBody]  List<Guid> input)
        {
            try
            {
                await _inStockVoucherService.SubmitInStockVoucher(input);
            }
            catch (Exception ex)
            {
                return ResponseResult.Fail(ex.Message);
            }
            return ResponseResult.Success("操作成功！");
        }
    }
}
